package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private static final String TAG = "aaa";
     TextView out;
     EditText input;
    EditText input1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        out= findViewById(R.id.txtout);

        input= findViewById(R.id.inp);
        input1= findViewById(R.id.inp1);
       // System.out.println("Hello from onCreate()....");
       // Log.i("aaa","msg from logi");
       // Log.i(TAG, "onCreate: msg abc 123 ");
       // Button btn=findViewById(R.id.btn);
      //  btn.setOnClickListener(new View.OnClickListener() {
        //    @Override
          //  public void onClick(View v) {
            //    Log.i(TAG, "onClick: 11223333333333");
            //}
        //});
    }


    public void myClick(View v) {
      //  Log.i(TAG,"onClick:click1111111");
        String s1= input.getText().toString();
        String s2= input1.getText().toString();
        String s3 = String.valueOf(Double.parseDouble(s2)*Double.parseDouble(s2));
        String s4 = String.format("%.2f",Double.parseDouble(s1)/Double.parseDouble(s3));
        double x=Double.parseDouble(s4);
        if (x<18.5){
              String s5="偏瘦，请适当增加饮食";
            out.setText("您的健康指数为："+s4+"\n对您的健康建议为："+s5);
        }else if (x<=25 && x>=18.5){
              String s5="健康体型，请保持";
            out.setText("您的健康指数为："+s4+"\n对您的健康建议为："+s5);
        }else if(x<=28 && x>25){
            String s5="超重，请适当减少饮食";
            out.setText("您的健康指数为："+s4+"\n对您的健康建议为："+s5);
        }else if(x>28){
            String s5="肥胖，请减少饮食或及时就医";
            out.setText("您的健康指数为："+s4+"\n对您的健康建议为："+s5);
        }
    }
}